const { defineConfig } = require('@vue/cli-service')
const CompressionWebpackPlugin = require('compression-webpack-plugin')
module.exports = defineConfig({
  transpileDependencies: true,
  assetsDir: 'statics',
  configureWebpack: {
    plugins: [
      new CompressionWebpackPlugin({
        test: /\.js$|\.html$|\.css$/,  // 匹配需要压缩的文件类型
        threshold: 10240,              // 10KB 以上的文件才会被压缩
        deleteOriginalAssets: false    // 是否删除原文件
      })
    ]
  },
  chainWebpack: (config) => {
    config.plugin('define').tap((definitions) => {
      Object.assign(definitions[0], {
        __VUE_OPTIONS_API__: 'true',
        __VUE_PROD_DEVTOOLS__: 'false',
        __VUE_PROD_HYDRATION_MISMATCH_DETAILS__: 'false'
      })
      return definitions
    })
  },
})
